/* Copyright (C) 2008, 2009, 2010 Faindu GmbH, Switzerland.
* All Rights Reserved. The following is Source Code and is subject to all restrictions 
* on such code as contained in the license accompanying this project. */
package blocstac.editimage.zoom
{

import blocstac.editimage.base.StateManager;

import flash.display.Sprite;
import flash.events.Event;

/**
 * The user drags these "buttons" to edit the image.
 */
public class ZoomTool
{
	private var _stateManager:StateManager	
	private var _zoomComponent:ZoomComponent
	
	function ZoomTool(stateManager:StateManager, zoomComponent:ZoomComponent) {
		_stateManager = stateManager
		_zoomComponent = zoomComponent
	}

	//--------------------------------------------------------------------------
	//
	//  Methods
	//
	//--------------------------------------------------------------------------
	public function init(toolsComponent:Sprite): void {
		_zoomComponent.addEventListener(Event.CHANGE, zoomChangeEvent)
	}
	
	private function zoomChangeEvent(event:Event):void {
		_stateManager.updateUserViewScale(_zoomComponent.value * 0.01)
		_zoomComponent.dispatchEvent(new ZoomOrPanEvent())
	}
	
}
}